package Test8;

import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Demo3 {
    public static void main(String[] args) throws IOException {
        File src=new File("D:\\Test.zip");
        File dec=new File("D:\\Test2.zip");
        method(src,dec);
    }public static void method(File src,File dec) throws IOException {
        ZipInputStream zis=new ZipInputStream(new FileInputStream(src));
        ZipEntry ze;
        while((ze=zis.getNextEntry())!=null){
            if (ze.isDirectory()){
                File dir=new File(dec,ze.toString());
                dir.mkdirs();
            }else {
                FileOutputStream fos=new FileOutputStream(new File(dec,ze.toString()));
                int b;
                while((b=zis.read())!=-1){
                    fos.write(b);
                }
                fos.close();
                zis.closeEntry();
            }
        }
        zis.close();
    }
}
